var $ = require("jquery");
var base = require("../base.js");


module.exports = {

	initBar:function(cmd,course){
		cmd==1&&$("#span-cmd").text('在线练习');
		cmd==2&&$("#span-cmd").text('模拟测试');
		cmd==3&&$("#span-cmd").text('错题练习');

		$("#span-course").text(course);
	},
	 
	renderQuesType: function(list) {
		var formater = '<label class="checkbox-inline">\
					<input type="checkbox" name="questype" id="inlineCheckbox1" value="{}"> {}\
					</label>';
		var str="";
		list.forEach(function(item,index){
			str+=base.format(formater,[item.value,item.key]);
		})
		$("#questypes").append(str);
	},
	
	renderQues: function(list) {
		var htmlformater = '<div class="panel panel-info" > \
			<div class="panel-heading">\
			<h3 class="panel-title">题{}. {}---(题库：{})</h3>\
			</div>\
			<div class="panel-body">{}</div>\
			<div class="panel-footer" id="footer{}"></div>\
			</div>';
		$("#ques-content").empty();
		var str = "";
		for (var index = 0; index < list.length; index++) {
			var ques = list[index];
			var formatstr = '<div class="radio"><label><input type="radio" name="{}" id="input" value="{}" >{}</label></div>';
			var html = base.format(formatstr, [ques.id, "a", ques.sa]);
			html += base.format(formatstr, [ques.id, "b", ques.sb]);
			html += ques.sc ? base.format(formatstr, [ques.id, "c", ques.sc]) : "";
			html += ques.sd ? base.format(formatstr, [ques.id, "d", ques.sd]) : "";
			html += ques.se ? base.format(formatstr, [ques.id, "e", ques.se]) : "";
			html += ques.sf ? base.format(formatstr, [ques.id, "f", ques.sf]) : "";

			str += base.format(htmlformater, [index+1, ques.question, ques.id, html, ques.id]);
		}
		$("#ques-content").append(str);
	},

}